package com.fangwei.controller;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.fangwei.pojo.User;

@Controller
@RequestMapping("/hello")
public class HelloController {

    @RequestMapping(value="/hw",method=RequestMethod.GET)
    @ResponseBody
    public String index() {
        return "Hello World";
    }
    
    @RequestMapping(value="/index",method=RequestMethod.POST)
    public String index2(Model map) {
    	List<User> users = new ArrayList<User>();
    	User user = new User();
    	user.setId(1L);
    	user.setUserName("zhangsan");
    	user.setPassword("1234");
    	User user2 = new User();
    	user2.setId(1L);
    	user2.setUserName("lisi");
    	user2.setPassword("8888");
    	users.add(user);
    	users.add(user2);
    	map.addAttribute("users",users);
    	map.addAttribute("name","haha");
        return "index";
    }
}